const ChildProcess = require('child_process');

function PromisifyExec(cmd) {
    return new Promise(resolve => {
        ChildProcess.exec(cmd, (error, stdout, stderr) => {
            if (error || stderr) {
                console.log(error, stderr)
            }
            if (stdout) {
                resolve(stdout.trim())
            } else {
                resolve('')
            }
        })
    })
}

module.exports = {
    PromisifyExec: PromisifyExec
}
